package Logica;

import DAO.Conexion;
import DAO.TreatmentDao;

import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class Treatment1 {
  // --Desaparece--
  //Primary Key
  private int TreatmentNumber;
  //Attributes.
  private int ExaminationNumber;
  private String description = new String();
  private float cost;
  private float quantity;
  private String observations = new String();
  private Date beginDate;
  private Date endDate;

  TreatmentDao td = new TreatmentDao();


  public Treatment1() {
  }

  public Treatment1(int TreatmentNumber, int ExaminationNumber,
                   String description, float cost, float quantity,
                   String observations, Date beginDate, Date endDate,
                   TreatmentDao td) {
    super();
    this.TreatmentNumber = TreatmentNumber;
    this.ExaminationNumber = ExaminationNumber;
    this.description = description;
    this.cost = cost;
    this.quantity = quantity;
    this.observations = observations;
    this.beginDate = beginDate;
    this.endDate = endDate;
    this.td = td;
  }
  


  public void setTreatmentNumber(int TreatmentNumber) {
    this.TreatmentNumber = TreatmentNumber;
  }

  public int getTreatmentNumber() {
    return TreatmentNumber;
  }

  public void setDescription(String description) {
    this.description = description;
  }

  public String getDescription() {
    return description;
  }

  public void setCost(float cost) {
    this.cost = cost;
  }

  public float getCost() {
    return cost;
  }

  public void setQuantity(float quantity) {
    this.quantity = quantity;
  }

  public float getQuantity() {
    return quantity;
  }

  public void setObservations(String observations) {
    this.observations = observations;
  }

  public String getObservations() {
    return observations;
  }

  public void setBeginDate(Date beginDate) {
    this.beginDate = beginDate;
  }

  public Date getBeginDate() {
    return beginDate;
  }

  public void setEndDate(Date endDate) {
    this.endDate = endDate;
  }

  public Date getEndDate() {
    return endDate;
  }

  public void setExaminationNumber(int ExaminationNumber) {
    this.ExaminationNumber = ExaminationNumber;
  }

  public int getExaminationNumber() {
    return ExaminationNumber;
  }

  public void setTd(TreatmentDao td) {
    this.td = td;
  }

  public TreatmentDao getTd() {
    return td;
  }

  public Object[][] DarDatosGuiTratamiento() {
    Object[][] datos = new Object[100][100];
    datos = td.DatosTratamientoTabla();

    return datos;
  }

  public void modificaTreatmentCantidad(String nuevoCant, String NumTreat) {
    System.out.println(NumTreat);
    int numtreatment = Integer.valueOf(NumTreat);
    System.out.println(numtreatment);
    
    int canti = Integer.valueOf(nuevoCant);
    td.modificaTreatmentCantidad(numtreatment, canti);
  }

  public void modificaTreatmentObserv(String NumTreat, String obs) {
    int numtreatment = Integer.getInteger(NumTreat);
    String observ = obs;
    td.modificaTreatmentObserv(numtreatment, observ);
  }

  public void modificaTreatmentDateBeg(String NumTreat, String begin) {
    int numtreatment = Integer.getInteger(NumTreat);
    Date datB = Date.valueOf(begin);
    td.modificaTreatmentDateBeg(numtreatment, datB);
  }

  public void modificaTreatmentDateEnd(String NumTreat, String end) {
    int numtreatment = Integer.getInteger(NumTreat);
    Date datEnd = Date.valueOf(end);
    td.modificaTreatmentDateEnd(numtreatment, datEnd);
  }

  public void modificaTreatmentExaNum(String NumTreat, String numEx) {
    //modificaTreatmentExaNum(nuevoNoEx,NumTreat);
    int numtreatment = Integer.valueOf(NumTreat);
    int numEx1 = Integer.valueOf(numEx);
    td.modificaTreatmentExaNum(numtreatment, numEx1);
  }

  public void modificaDesc(String nuevoDes, String NumTreat) {
    int numtreatment = Integer.valueOf(NumTreat);
    td.modificaTreatmentDescripcion(numtreatment, nuevoDes);
  }

  public void modificaCost(String nuevoCost, String NumTreat) {
    int numtreatment = Integer.valueOf(NumTreat);
    float nuevocost = Float.valueOf(nuevoCost);
    td.modificaTreatmentCosto(numtreatment, nuevocost);

  }


  public boolean creaTratamiento( String Des, 
                                 String cost, String Cant, String Obs,
                                 String FechaIn, String FechaFin,String numExa) {
    System.out.println("Entre 1");
    float cost1 = Float.parseFloat(cost);
    int canti=Integer.parseInt(Cant);
    Date din=Date.valueOf(FechaIn);
    Date dFin=Date.valueOf(FechaFin);
    int exanum=Integer.parseInt(numExa);
    System.out.println("Entre 2");
    return td.creaTratamiento(Des,cost1,canti,Obs,din,dFin,exanum);

  }
  
  public boolean EliminarTratamiento(String NumTrea){
    return td.eliminarTratamiento(Integer.valueOf(NumTrea));   
    
  }
}
